home *** CD-ROM | disk | FTP | other *** search
/ Developer Helper 1: Phil & Dave's Excellent CD / Excellent CD HFS.raw / Utilities / ResEdit / Examples / CExamples / Source / ResEd.h < prev    next >
Text File  |  2022-08-05  |  12KB  |  325 lines

  1. /*
  2. File ResEd.p
  3.  
  4. Copyright Apple Computer, Inc. 1984-1989
  5. All rights reserved.
  6.  
  7.     Resource editor interface unit for instances of editors and pickers. This should be
  8.     included by any C implementation of a resource editor or picker.  The
  9.     companion file ResDisp.a.o should be linked with the c module to build
  10.     the file for inclusion in ResEdit.
  11.  
  12.     Pickers are given a resource type and should display all of that type in 
  13.     the current resfile in a suitable format.     If the picker is given an open call 
  14.     AND there's a compatible editor, it should give birth to the Editor.  The editor
  15.     is given a handle to the resource object and it should open up an edit
  16.     window for the user.
  17.  
  18.     Note that anybody can open pickers and editors so, for instance, a dialog item list
  19.     editor might open an icon Picker for the user to choose an appropriate icon.
  20.     The user could also, while in the icon picker, open the icon editor to create
  21.     a new icon if desired.
  22.   
  23. */
  24.  
  25. #include    <types.h>
  26. #include    <quickdraw.h>
  27. #include    <lists.h>
  28. #include    <controls.h>
  29. #include    <windows.h>
  30. #include    <events.h>
  31. #include    <dialogs.h>
  32.  
  33. /* Standard menus exported by ResEdit */
  34.  
  35. #define    fileMenu        2
  36.  
  37. #define    newItem            1
  38. #define    openItem        2
  39. #define openAsItem        3
  40. #define    opnOther        3
  41. #define openGeneralItem 4
  42. #define    opnGnrl            4
  43.  
  44. #define    closeItem        6
  45. #define    saveItem        7
  46. #define    revertItem        8
  47. #define    getInfoItem        9
  48. #define preferencesItem 10
  49. #define    transferItem    12
  50. #define    quitItem        13
  51.  
  52. /* Masks for AbleMenu - normally not used directly. */
  53. #define    newMask         2
  54. #define    openMask         4
  55. #define    openAsMask         8
  56. #define    openGnrlMask    0x10
  57. #define    closeMask        0x40
  58. #define    saveMask        0x80
  59. #define    revertMask        0x100
  60. #define    getInfoMask        0x200
  61. #define preferencesMask 0x400
  62. #define    transferMask    0x1000
  63. #define    quitMask        0x2000
  64. #define    disabledMask    0xFFFFC001
  65.  
  66. /* Mask combinations to be used in calls to AbleMenu. */
  67. #define    fileQuit        disabledMask + preferencesMask + transferMask + quitMask
  68. #define fileClose        fileQuit + closeMask + saveMask
  69. #define    fileAll            fileClose + newMask + openMask + openAsMask + openGnrlMask + revertMask + getInfoMask
  70. #define    fileNoRevert    fileAll - revertMask
  71. #define    fileNoInfo        fileAll - getInfoMask
  72. #define    fileNoNew        fileAll - newMask 
  73. #define    fileNoOpen        fileClose + newMask + revertMask + getInfoMask
  74. #define    fileNoNewOrOpen    fileNoOpen - newMask
  75. #define    fileTop            fileClose + revertMask + getInfoMask
  76. #define    fileOpQuOnly    fileQuit + openMask + openAsMask + openGnrlMask
  77. #define    fileROMStuff    fileQuit  + openMask + openAsMask + openGnrlMask + closeMask + getInfoMask
  78. #define    fileDiskStuff    fileQuit + newMask + openMask + closeMask + getInfoMask
  79.  
  80. #define    editMenu    3
  81.  
  82. #define    undoItem    1
  83. #define    cutItem     3
  84. #define    copyItem    4
  85. #define    pasteItem    5
  86. #define    clearItem    6
  87. #define    dupItem     8
  88.  
  89. /* Masks for AbleMenu - normally not used directly. */
  90. #define undoMask            0x2
  91. #define cutMask                0x8
  92. #define editCopyMask        0x10
  93. #define pasteMask            0x20
  94. #define clearMask            0x40
  95. #define duplicateMask        0x100
  96. #define editDisabledMask    0xFFFFFE01
  97.  
  98. /* Mask combinations to be used in calls to AbleMenu. */
  99. #define editNone        editDisabledMask
  100. #define editClear        editNone + clearMask
  101. #define editCopy        editNone + editCopyMask
  102. #define editPaste        editNone + pasteMask
  103. #define editUndoPasteOnly editPaste + undoMask
  104. #define editDup            editClear + duplicateMask
  105. #define editNoDup        editNone + cutMask + editCopyMask + pasteMask + clearMask /* No dup or undo */
  106. #define editNoUndo        editNoDup + duplicateMask
  107. #define editUndNoDup    editNoDup + undoMask
  108. #define editAll            editNoUndo + undoMask
  109. #define editAcc         editUndNoDup
  110.  
  111. #define editorNameChr 0        /* First char of the name for editors */
  112.     
  113. /* Standard strings available by calling GetStr. */
  114. #define editStrings        130            /* Resource ID of STR# resource containing the strings. */
  115. #define undoChangeStr    1
  116. #define redoChangeStr    2
  117. #define undoCutStr        3
  118. #define redoCutStr        4
  119. #define undoCopyStr        5
  120. #define redoCopyStr        6
  121. #define undoClearStr    7
  122. #define redoClearStr    8
  123. #define undoTypingStr    9
  124. #define redoTypingStr    10
  125. #define undoPasteStr    11
  126. #define redoPasteStr    12
  127. #define undoStr            13
  128.     
  129. #define miscStrings                129    /* Resource ID of STR# resource containing the strings. */
  130. #define fromStr                    1        /* String for window titles. */
  131. #define fullWindowStr             38        /* String for the resizeWind menu item */
  132. #define ownerWindowWindowStr    39
  133. #define newItemStr                 40        /* Enter new item number */
  134. #define selectItemStr             41        /* Open which item? */
  135. #define clipBoardErrorStr        42        /* Error accessing the Clipboard. */ 
  136. #define sndErrorStr                43        /* Error playing a sound. */
  137. #define openAsDotStr            44        /* Open As ... */
  138. #define openAsDITMStr            45        /* Open As Dialog Item */
  139.  
  140. #define arrowCursor -1    /* Used in the call to SetTheCursor to set the arrow cursor. */
  141.  
  142. #define minPickStdWidth 150
  143. #define minPickStdRows  4
  144.  
  145. #define okChoice 1
  146.     
  147. #define revertResourceAlert 1387        /* Used by all editors to when revert is selected. */
  148.  
  149. /* Alert kinds used by the DisplayAlert procedure. */
  150. #define displayTheAlert     0
  151. #define displayStopAlert     1
  152. #define displayNoteAlert     2
  153. #define displayCautionAlert    3
  154.  
  155.     typedef unsigned char Str64[65];
  156.  
  157.    /* map entry definition for new resource manager call */
  158.     typedef struct {
  159.            short        rID;
  160.         short        rNameOff;
  161.         long        rLocn;
  162.         Handle        rHndl;
  163.     } ResMapEntry;
  164.  
  165.     /* This structure is used by the GetQuickDrawVars procedure. */
  166.     typedef struct  {
  167.         long     randSeed;
  168.         BitMap     screenBits;
  169.         Cursor     arrow;
  170.         Pattern dkGray;
  171.         Pattern ltGray;
  172.         Pattern gray;
  173.         Pattern black;
  174.         Pattern white;
  175.         GrafPtr thePort;
  176.     } QuickDrawVars;
  177.     typedef    QuickDrawVars    *pQuickDrawVars;
  178.     
  179.     /* Each driver has its own object handle. This has to start with a handle
  180.         to its parent's object followed by the name distinguishing the father
  181.         This name will be part of the son's window title. The next field should
  182.         be the window of the obj (may be used by son to get back to the father
  183.         (through the refcon in the windowRec). The next field is the rebuild flag
  184.         used to indicate that a windows data (e.g. a pickers list) needs to be
  185.         recalculated at the next opportunity.  The rest of the handle can be of
  186.         any format.  The name for pickers should be the name of the file or disk.
  187.         For editors, the name should be the complete name (not the windows title)
  188.         preceded by an editorNameChr character (see const above).  An example of a
  189.         complete name would be "ALRT ID = -1234 from AFile".  This name is used to
  190.         uniquely identify a window. 
  191.         
  192.         See the manual for detailed documentation of this interface file. */
  193.  
  194.     typedef    struct ParentRec {
  195.         struct    ParentRec    **father;
  196.         Str64                name;        /* Max 64 characters */
  197.         WindowPeek            wind;
  198.         Boolean                rebuild;    /* flag set by son to indicate that world         */
  199.                                         /* has changed so father should rebuild list     */
  200.     } ParentRec;
  201.     
  202.     typedef    ParentRec    *ParentPtr;
  203.     typedef    ParentPtr    *ParentHandle;
  204.  
  205. /* Standard picker record */
  206.  
  207.     typedef struct PickRec {
  208.         ParentHandle        father;            /* Back ptr to dad             */
  209.         Str64                fName;            /* Max 64 characters.         */         
  210.         WindowPtr            wind;            /* Directory window         */
  211.         Boolean                rebuild;
  212.         short                pickID;            /* ID of this picker         */
  213.         ResType                rType;            /* Type for this picker     */
  214.         short                rNum;            /* resfile number             */
  215.         long                rSize;            /* size of a null resource     */
  216.         short                nInsts;            /* Number of instances         */
  217.         ListHandle            instances;        /* List of instances         */
  218.         Ptr                    drawProc;        /* List draw proc             */
  219.         ControlHandle        scroll;            /* Scroll bar                 */
  220.     } PickRec;
  221.     
  222.     typedef    PickRec    *PickPtr;
  223.     typedef    PickPtr    *PickHandle;
  224.  
  225.  
  226. /* These routines are used to start pickers and editors.*/
  227.  
  228. pascal void            GiveEBirth(Handle resHandle, PickHandle pick);
  229. pascal void            GiveThisEBirth(Handle resHandle, PickHandle pick, ResType openThisType);
  230. pascal void            GiveSubEBirth(Handle resHandle, PickHandle pick);
  231.  
  232. /* These routines are used to feed events and menu calls to the appropriate picker or editor. */
  233.  
  234. pascal void            CallInfoUpdate(short oldID, short newID, long object, short id);
  235. pascal void         PassMenu(short menu, short item, ParentHandle father);
  236.  
  237. /* Window Utilities */
  238.  
  239. pascal Boolean        AlreadyOpen (StringPtr windowTitle, StringPtr windowName, ParentHandle father);
  240. pascal WindowPtr    CWindSetup (short width, short height, StringPtr t, StringPtr s);
  241. pascal WindowPtr    EditorWindSetup (Boolean color, short width, short height, StringPtr windowTitle, 
  242.                                      StringPtr windowName, Boolean addFrom, ParentHandle father);
  243. pascal void            GetWindowTitle (StringPtr windowTitle, StringPtr windowName, Boolean addFrom,
  244.                                     ParentHandle father);
  245. pascal void            SetETitle(Handle h, StringPtr str);
  246. pascal WindowPtr    WindAlloc(void);
  247. pascal void            WindReturn(WindowPtr w);
  248. pascal ListHandle    WindList(WindowPtr w, short nAcross, Point cSize, short drawProc);
  249. pascal void            WindOrigin(WindowPtr);
  250. pascal WindowPtr    WindSetup(short width, short height, StringPtr t, StringPtr s);
  251.  
  252.  
  253. /* Extended Resource Manager */
  254.  
  255. pascal short        CurrentRes(void);
  256. pascal Handle        Get1Index(ResType, short index);
  257. pascal Handle        Get1Res(ResType, short id);
  258. pascal Boolean        NeedToRevert (WindowPtr myWindow, Handle theRes);
  259. pascal void            RemoveResource (Handle theRes);
  260. pascal Boolean        RevertThisResource (ParentHandle theObj, Handle theRes);
  261. pascal short        SysResFile(void);
  262.  
  263. /* Miscellaneous utilities */
  264.  
  265. pascal void            Abort(void);
  266. pascal void            AbleMenu(short menu, long enable);
  267. pascal Boolean        AddNewRes(Handle hNew, ResType t, short idNew, StringPtr s);
  268. pascal void            BubbleUp(Handle);
  269. pascal short        BuildType(ResType t, ListHandle l);
  270. pascal Boolean        CheckError(short err, short msgID);
  271. pascal Boolean        CloseNoSave(void);
  272. pascal void            ConcatStr(StringPtr str1, StringPtr str2);
  273. pascal short        DefaultListCellSize(void);
  274. pascal short        DisplayAlert(short which, short id);
  275. pascal void            FixHand(long s, Handle h);
  276. pascal void            FlashDialogItem (DialogPtr dp, short item);
  277. pascal void            FrameDialogItem (DialogPtr dp, short item);
  278. pascal pQuickDrawVars GetQuickDrawVars(void);
  279. pascal void            GetStr(short num, short list, StringPtr str);
  280. pascal void            GrowMyWindow (short minWidth, short minHeight, WindowPtr windPtr, ListHandle);
  281. pascal Boolean        HandleCheck(Handle h, short msgID);
  282. pascal void            MetaKeys(short *cmd, short *shift, short *opt);
  283. pascal Handle        NewRes(long s, ResType t, ListHandle l, short *n);
  284. pascal void            PickEvent(EventRecord *evt, PickHandle pick);
  285. pascal void            PickInfoUp(short oldID, short newID, PickHandle pick);
  286. pascal void            PickMenu(short menu, short item, PickHandle pick);
  287. pascal short        PickStdRows(void);
  288. pascal short        PickStdWidth(void);
  289. pascal short        ResEdID(void);
  290. pascal void            SendRebuildToPickerAndFile (ResType theType, ParentHandle parent) ;
  291. pascal void            SetResChanged(Handle h);
  292. pascal void            SetTheCursor (short whichCursor);
  293. pascal void            ShowInfo(Handle h, ParentHandle father);
  294. pascal void            TypeToString(ResType t, StringPtr s);
  295. pascal void            UseAppRes(void) = 
  296.                     { 0x3f38, 0x0900,     /* move.w    CurApRefNum,-(sp) */ 
  297.                       0xa998 };            /* _UseResFile */ 
  298. pascal Boolean        WasAborted(void);
  299.  
  300. /* Routines that are used internally withing ResEdit and may be useful in other
  301.     circumstances. */
  302.     
  303. pascal void            CallEBirth(Handle thing, ParentHandle parent, short id);
  304. pascal void            CallEvent(EventRecord *evt, long object, short id);
  305. pascal void            CallMenu(short menu, short item, long object, short id);
  306. pascal void            CallPBirth(ResType t, ParentHandle parent, short id);
  307. pascal Handle        CopyRes(Handle *h, Boolean makeID, short resNew);
  308. pascal void            DoKeyScan(EventRecord *evt, short offset, ListHandle lh);
  309. pascal void            DoListEvt(EventRecord e, ListHandle l);
  310. pascal Handle        DupPick(Handle h, Cell c, PickHandle pick);
  311. pascal Boolean        GetType(Boolean templatesOnly, StringPtr s);
  312. pascal void            KillCache(void);
  313. pascal void            RCalcMask(Ptr srcPtr, Ptr dstPtr,
  314.                            short srcRow, short dstRow, short height, short words);
  315. pascal short        ResEditRes(void) =
  316.                     {0x3eB8, 0x0900};    /* move.w    CurApRefNum,(sp) */
  317. pascal void            ScrapCopy(Handle *h);
  318. pascal void            ScrapEmpty(void);
  319. pascal void            ScrapPaste(Boolean pasteAll, ResType typeToPaste, short resFile);
  320.  
  321. /* Obsolete routines that are left in for compatability. */
  322.  
  323. pascal Boolean        RevertResource(Handle);
  324.  
  325.